#include "MsgRequest.h"

namespace RobotControl{
namespace Common{

MsgRequest::MsgRequest(zmq::context_t *ctx)
	: m_socket(*ctx, ZMQ_REQ)
{
}

/// \brief 配置主题
bool MsgRequest::config(const std::string &topic)
{
#if 0
	try{
		m_socket.connect(topic);
	}
	catch(std::exception &e)
	{
		//Log::RobotLog(Log::Error) << "error: " << e.what() << std::endl;
		return false;
	}
#else
    m_socket.connect(topic);
#endif
	return true;
}

/// \brief 请求数据
/// \param[in] req: 请求的数据
/// \param[in] rep: 应答的数据
void MsgRequest::request(zmq::message_t &req, zmq::message_t &rep)
{
	m_socket.send(req);
	m_socket.recv(&rep);
}

}	// Common
}	// RobotControl
